Parameter Handling
In this section specify how TPT and MATLAB communicate when exchanging parameter values. All settings can be changed separately, and read or write can be disabled in case these features are not needed. The default setting for TPT is to exchange parameters via MATLAB workspace (WS); this configuration is adequate for most cases (importing, reading, and writing).
The following options are available for importing, reading and writing:
IMPORT parameters (MATLAB > TPT)
Analyze MATLAB workspace, Simulink DD or TargetLink DD automatically (default)
Automatically import/read from MATLAB or write parameters to MATLAB workspace.
Use custom MATLAB script/function
Parameters can be exchanged via a custom MATLAB script or function. This script can especially be used to define parameters as maps, curves, or structs in TPT. Use the following structures to assign the values to the specified parameters:
map:
tpt_read(<i>).name='<nameInTPT>';
tpt_read(<i>).type='map';
tpt_read(<i>).value.xaxis=<value>;
tpt_read(<i>).value.yaxis =<value>;
tpt_read(<i>).value.values=<value>;
curve:
tpt_read(<i>).name='<nameInTPT>';
tpt_read(<i>).type='curve';
tpt_read(<i>).value.axis= <value>;
tpt_read(<i>).value.values =<value>;
struct:
When using the type struct
, a field's value may not be a structure itself again.
tpt_read(<i>).name='<nameInTPT>';
tpt_read(<i>).type='struct';
tpt_read(<i>).value.<field1>=<value>;
tpt_read(<i>).value.<...> =<value>;
everything else:
TPT recognizes the data type of arrays, matrix, multidimensional arrays, double, boolean, integer, enumeration, and so forth automatically by its <value>.
tpt_read(<i>).name='<nameInTPT>';
tpt_read(<i>).type='auto';
tpt_read(<i>).value=<value>;
In case you are using Simulink.Parameter objects, Simulink.Signal objects and embedded.fi objects, these objects may not be set directly for a <value>
. Extract their values in your script or function and use the extracted value for <value>
. For example, params(1).value = mySimPar.Value; for a Simulink.Parameter
. Enumerations like Simulink.IntEnumType can however be used as <value>
.
READ parameters before each test execution (MATLAB > TPT)
Disable reading parameters
No parameters are read from MATLAB.
Read parameters as specified for IMPORT parameters (default)
All parameters are read from MATLAB.
Read each parameter using custom expression
Individual parameters are read by means of a ${paramname}
expression. For example when you enter ${foo}
and ${bar}
, MATLAB returns the value only of these two parameters. Use the button at the end of the line to reset your changes.
WRITE parameters before each test execution (TPT > MATLAB)
Disable writing parameters
No parameters are written to MATLAB.
Write parameters to MATLAB workspace, Simulink D or TargetLink DD automatically (default)
All parameters are written to MATLAB.
TargetLink: Assign parameter values to memory in SiL/PiL mode
This way the code for the parameters can be reused so there is no need to regenerate the code. This option is not supported for Simulink.Parameter objects. Note the TargetLink limitations for parameter modifications. Refer to the TargetLink manual for detailed information.
Write parameters via custom MATLAB script/function
Write each parameter using custom expression
Parameters are written by a ${paramname}=${paramvalue}
command. For example when you write ${foo}=${123}
, MATLAB writes the value 123
to the parameter foo
. foo
can be a scalar parameter, an array, a curve, or a map. Any of these types must be previously entered using the Declaration Editor, see Signal Types - Parameter.
Consider a parameter
Consider two functions in MATLAB:
Set the exchange preferences as shown below: |